package main

import (
	"bufio"
	"fmt"
	"os"
)

const (
	INIT     = 0
	ZERO     = 1
	NON_ZERO = 2
)

// exit when EOF
func advance_or_end(br *bufio.Reader, b *byte) {
	if nb, err := br.ReadByte(); err == nil {
        *b = nb
	} else {
        os.Exit(1) 
    }
}

func produce(val uint64) {
	fmt.Print(val)
	os.Exit(0)
}

func main() {
	br := bufio.NewReader(os.Stdin)

	state := 0
	var b byte
	var val uint64

	advance_or_end(br, &b)

	for {
		switch state {
		case INIT:
			if b == '0' {
				state = ZERO
			} else if b >= '1' && b <= '9' {
				val = uint64(b - '0')
				state = NON_ZERO
			}
			advance_or_end(br, &b)
		case ZERO:
			if b == '%' {
				produce(0)
			} else {
				state = INIT
			}
		case NON_ZERO:
			if b == '%' {
				produce(val)
			} else if b >= '0' && b <= '9' {
				val = val*10 + uint64(b-'0')
				advance_or_end(br, &b)
			} else {
				state = INIT
				advance_or_end(br, &b)
			}
		default:
			fmt.Println("Internal Error: unexpected state")
			os.Exit(2)
		}
	}
}
